﻿using CommonEntity;
using CommonLibary;
using NetCore6WebAPITestOneEntity;
using NetCore6WebAPITestOneRequestEntity;
using NetCroe6WebAPITestOneResponse;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NetCroe6WebAPITestOneBusiness
{
    public class UserinfoMongoDbBusiness:BaseBusiness
    {
        UserinfoMongoDbResponse _userinfoMongoDbResponse;


        public UserinfoMongoDbBusiness(LoggerSingletonHelper loggerSingletonHelper, UserinfoMongoDbResponse userinfoMongoDbResponse) : base(loggerSingletonHelper)
        {
            _userinfoMongoDbResponse = userinfoMongoDbResponse;
        }

        public ViewModelBase InserUserinfo(UserinfoMongodbModel userinfo)
        {
            return DoFunc<ViewModelBase>(() =>
            {
                userinfo.UserID = Guid.NewGuid().ToString();
                userinfo.CreateTime = DateTime.Now;
                userinfo.UpdateTime = DateTime.Now;

                ViewModelBase vb = new ViewModelBase();
                vb.data = _userinfoMongoDbResponse.InserUserinfo(userinfo);
                return vb;
            });
        }

        public ViewModelBase GetUserinfo(string userid)
        {
            return DoFunc<ViewModelBase>(() =>
            {
                ViewModelBase vb = new ViewModelBase();
                vb.data = _userinfoMongoDbResponse.GetUserinfo(userid);
                return vb;
            });
        }

        public ViewModelBase GetUserinfoPage(UserinfoMongodbPageRequestViewModel para)
        {
            return DoFunc<ViewModelBase>(() =>
            {
                

                ViewModelBase vb = new ViewModelBase();
                vb.data = _userinfoMongoDbResponse.GetUserinfoPage(para);
                return vb;
            });
        }
    }
}
